# -*- coding: utf-8 -*-

def ShellSort(arr):
    n = len(arr)
    endi = 0
    if n == 1:
        return 1
    space = n // 3
    while space > 0:
        for i in range(space):
            key = arr[i]
            j = 0
            while i+(j+1)*space < n:
                print('交换开始下载下标数%d，交换结束%d' % (j, i+(j+1)*space))
                if space > 1:
                    if arr[i+(j+1)*space] < key:
                        arr[i+j*space] = arr[i+(j+1)*space]
                        endi = i+(j+1)*space
                else:
                    if arr[j] > arr[j+1]:
                        arr[j], arr[j+1] = arr[j+1], arr[j]
                j += 1
            if arr[i] != key:
                arr[endi] = key
        space -= 1

s1 = [18,3,0,5,2,10,7,15,38,100]    
ShellSort(s1)
print(s1)
                